package com.esun.cheetah.biz.personal.lotteryrecord;

import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Handler;

import com.esun.cheetah.biz.personal.personalinfo.UserInfo;
import com.esun.cheetah.config.BizCode;
import com.esun.cheetah.config.Key;
import com.esun.cheetah.network.AbsInferiorityCommunicater;
import com.esun.util.log.EDebug;
/**
 * 
 * @Package com.esun.cheetah.biz.personal.lotteryrecord.SportteryFootballNormalBuyCommunicater
 * @ClassName: SportteryFootballNormalBuyCommunicater
 * @Description: TODO(SportteryFootballNormalBuyCommunicater)
 * @author handy <br/>
 * @date create at 2012-7-31 下午3:15:13
 *
 */
public class SportteryFootballNormalBuyCommunicater extends
		AbsInferiorityCommunicater {

	private String status;
	private String msg;

	private int zhushu;
	private int beishu;
	private String allmoney;
	private int guoguanType;
	private String codes;
	private String ratelist;
	private String sgtype;
	private String danma;

	public SportteryFootballNormalBuyCommunicater(Handler handler, int zhushu,
			int beishu, String allmoney, int guoguanType, String codes,
			String ratelist, String danma, String sgtype) {
		super(handler);
		// 必填3 自由过关 2 多串过关

		this.zhushu = zhushu;
		this.beishu = beishu;
		this.allmoney = allmoney;
		EDebug.o("allmoney------" + allmoney);
		this.guoguanType = guoguanType;
		this.codes = codes;
		this.ratelist = ratelist;
		this.sgtype = sgtype;
		this.danma = danma;
	}

	@Override
	public HashMap<String, String> comHashMap() {
		HashMap<String, String> hmJson = new HashMap<String, String>();

		hmJson.put(Key.KEY_ID, BizCode.GOUCAI);
		hmJson.put("lotid", "46");
		hmJson.put("title", "android复式");
		hmJson.put("sgtype", sgtype);
		hmJson.put("playid", "269");
		hmJson.put("zhushu", Integer.toString(zhushu));
		hmJson.put("beishu", Integer.toString(beishu));
		hmJson.put("allmoney", allmoney.toString());
		hmJson.put("gggroup", Integer.toString(guoguanType));
		hmJson.put("codes", codes);
		// hmJson.put("guoguanType",sgtype);
		hmJson.put("ratelist", ratelist);
		if (danma.equals(null)) {
			EDebug.o("无胆码");
		} else {
			hmJson.put("danma", danma);
		}
		hmJson.put("ck", UserInfo.getUserInfo().getCk());
		hmJson.put("IsCutMulit", "1");
		hmJson.put("anumber", "1");
		hmJson.put("buynumber", "1");
		hmJson.put("ishm", "0");
		// hmJson.put(Key.KEY_IMEI, imei);

		return hmJson;
	}

	@Override
	public void getJsonContent(String serverRes) throws JSONException {

		JSONObject json = new JSONObject(serverRes);
		status = json.getString(Key.STATUS);
		msg = json.getString(Key.MSG);

		EDebug.o("msg---" + msg);
		EDebug.o("status---" + status);

		JSONObject jsondata = new JSONObject(json.getString(Key.DATA));
		String money = jsondata.getString("usermoney");
		EDebug.o("money-----" + money);
		UserInfo.getUserInfo().setMoney(money);

		String pid = jsondata.getString("pid");
		EDebug.o("pid-----" + pid);
		UserInfo.getUserInfo().setPid(pid);
	}

	public String getMsg() {
		return this.msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public boolean isBuySucceed(int zhushu, int beishu, long l,
			int guoguanType, String codes, String sgtype) {
		return false;
	}

	public int getState() {
		return 0;
	}

	public String getErrorMSG() {
		return null;
	}

}
